import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns : BasicColumn[] = [
  //  {
  //  title: '协议ID',
  //  dataIndex: 'protocolId'
  // },
  {
    title: '协议名称',
    dataIndex: 'protocolName'
  },
  {
    title: '协议描述',
    dataIndex: 'protocolRemark'
  },
  {
    title: '创建时间',
    dataIndex: 'createTime'
  },
];

export const searchFormSchema : FormSchema[] = [
  {
    label: '协议名称',
    field: 'protocolName',
    component: 'Input'
  },
];

export const formSchema : FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'protocolId', component: 'Input', show: false },
  { label: '', field: 'isEdit', component: 'InputNumber', show: false },
  {
    label: '协议名称',
    field: 'protocolName',
    component: 'Input',
    colProps: { span: 22 },
    rules: [{ required: true, message: "请输入协议名称" }],
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '协议内容',
    field: 'protocolContent',
    slot: 'protocolContent',
    component: 'InputTextArea',
    colProps: { span: 22 },
    // componentProps: {
    //   placeholder: '请输入协议内容',
    //   rows: 4,
    // },
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '设备编码字段',
    field: 'deviceField',
    component: 'Input',
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  },
  {
    label: '协议描述',
    field: 'protocolRemark',
    component: 'Input',
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      if (values.isEdit != undefined && values.isEdit == true) {
        return true
      } else {
        return false
      }
    },
  }
];
